 <?php
 //session_start(); // To store the values and can be used in other php codes 
 function parks($txt,$lat,$lon)
  {
   if (isset($_GET['page'])) 
   { 
    $page = $_GET['page'];
    $page=mysql_real_escape_string($page); 
   }
    else $page=1;
   // $txt="parks";
    $llat=$lat-5;
    $hlat=$lat+5;
    $llon=$lon-5;
    $hlon=$lon+5;

$result=mysql_query("SELECT * FROM parks where category='$txt' and Loc_latitude BETWEEN $llat and $hlat and Loc_longitude BETWEEN $llon and $hlon") or die(mysql_error()); 
$rows = mysql_num_rows($result);//Here we count the number of results

$per_page = 5;//this is the maximum number of result to be displayed per page

//This tells us the page number of our last page 
$total_pages = ceil($rows/$per_page);
//echo"you are on page $page of $total_pages<br/>";
//if($page!=1)
//{ echo "<a href='parks_search.php?page=1'><<First</a>"." ";
 // $previous=$page-1;
  //echo "<a href='parks_search.php?page=$previous'><<Previous</a>";
//}
//if(($page!=1)&&($page!=total_pages))
  //echo "|";
  
  //if($page!= $total_pages)
  //{ $next=$page+1;
    //echo"<a href='parks_search.php?page=$next'>Next>></a>"." ";
    //echo"<a href='parks_search.php?page=$total_pages'>Last>></a>";
  //}
  //echo "<hr><br/>";
  
  $x=($page-1)*$per_page;
  $result=mysql_query("SELECT * FROM parks where category='$txt' and Loc_latitude BETWEEN $llat and $hlat and Loc_longitude BETWEEN $llon and $hlon ");// removed Limit $x,$per_page
  while($row=mysql_fetch_array($result))
   {
  	$array[]=$row;
    }
    
  return $array;
 // print_r($array); to recursively print a value!
  
mysql_close($con);
  }

  ?>
